MTB_robot add suction pad <<
Previous Next >> MTB_robot python remote api
MTB_robot add IK
使用老師的逆運動學函式求出終點位置的位移,使MTB_robot在coppeliasim裡可以順利達到老師要求的位置
W16_exam.7z error版本
W16_exam.7z
loop迴圈影片:
因為迴圈做不出來,發現到46號網站的內容,找出wait問題點後的操作狀態
參考40823246
正確位置的影片(鍵盤)
錯誤位置的影片,但是有求出a1與a2。
老師的程式
修改後的程式
-- The decimal point of number x is rounded to the nth place
function round(x, n)
n = math.pow(10, n or 0)
x = x * n
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
return x / n
end
-- radian to degree
deg = 180/math.pi
-- link 1 length
a1 =0.467
-- link 2 length
a2 =0.4
-- derivated based upon https://www.youtube.com/watch?v=IKOGwoJ2HLk&t=311s
function ik(x, y)
-- (x, y) need to be located inside the circle with radius a1+a2
if (x^2 + y^2) <= (a1+ a2)^2 then
q2 = math.acos((x^2+y^2-a1^2-a2^2)/(2*a1*a2))
q1 = math.atan2(y, x) - math.atan2((a2*math.sin(q2)), (a1+a2*math.cos(q2)))
return {round(q1*deg, 4), round(q2*deg, 4)}
else
print("Over range!")
-- end the script execution
os.exit()
end
end
theta = ik(-0.3, -0.55)
print(theta[1], theta[2])
lua 編譯網站:
MTB_robot add suction pad <<
Previous Next >> MTB_robot python remote api